package com.woniuxy.hrp.web;

import com.woniuxy.hrp.entity.ArrangeTime;
import com.woniuxy.hrp.service.ArrangeTimeService;
import com.woniuxy.hrp.unityhandler.ResponseEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@Transactional
@CrossOrigin
@RestController
public class ArrangeTimeConsoler {

    @Autowired
    private ArrangeTimeService arrangeTimeService;

    @RequestMapping("/api/arrangetime")
    public ResponseEntity<List<String>> getAll() {
        List<String> date = new ArrayList<>();
        arrangeTimeService.getByAll().forEach(d->{
            date.add(d.getStartTime()+"-"+d.getEndTime());
        });
        return new ResponseEntity<>("200", "success",date);
    }
}
